package cn.iocoder.yudao.module.nmkj.dal.mysql.companyintroduction;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.nmkj.dal.dataobject.companyintroduction.CompanyIntroductionDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.nmkj.controller.admin.companyintroduction.vo.*;

/**
 * 公司介绍 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface CompanyIntroductionMapper extends BaseMapperX<CompanyIntroductionDO> {

    default PageResult<CompanyIntroductionDO> selectPage(CompanyIntroductionPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CompanyIntroductionDO>()
                .eqIfPresent(CompanyIntroductionDO::getContent, reqVO.getContent())
                .eqIfPresent(CompanyIntroductionDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(CompanyIntroductionDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CompanyIntroductionDO::getStatus));
    }

    /**
     * 给用户端使用的 Mapper，只允许获得单一实例且是开启状态
     * @return 单一实例
     */
    default CompanyIntroductionDO selectSingle() {
        CompanyIntroductionPageReqVO reqVO = new CompanyIntroductionPageReqVO();
        reqVO.setStatus(1);
        reqVO.setPageNo(1).setPageSize(1);
        return selectOne(new LambdaQueryWrapperX<CompanyIntroductionDO>()
                .eqIfPresent(CompanyIntroductionDO::getStatus, reqVO.getStatus()));
    }

}